1. Field of the Description
The present description relates, in general, to memory management in computer systems and virtual machine environments, including Java® virtual machines (JVMs), and, more particularly, to methods and systems for providing garbage collection suited for large systems (e.g., with relatively large numbers of active application threads such as hundreds up to 1000 to 2000 or more threads) to reduce contention when accessing update buffers provided for or used by application threads (also known as mutator threads). Generally, though, the method applies to communicating any information from application/mutator threads to garbage collector (GC) threads (e.g., GC threads being a proxy for the GC/memory management system and buffers containing object reference update information providing just one example of such information). The method ensures that the application threads get better latencies, possibly at the expense of the GC threads (e.g., all threads are not treated equally with regard to latency in some of the embodiments of the described method).
2. Relevant Background
In a computer system, the effective control of the allocation of memory resources is desirable to the successful operation and scalability of the computer system (e.g., the whole hardware stack, operating system (OS), Java® virtual machines (JVMs), software, and the like). Software applications run more efficiently in environments in which steps are taken to proactively manage available memory resources to ensure that only those data objects that are currently being used are stored in memory, while unused entities or data objects are cleanly removed. In some systems and virtual machines (for example, the JVM), the system periodically performs garbage collection using one or more garbage collector (GC) threads. During garbage collection, the virtual machine scans the entire data object memory (or application heap) and finds which objects that have been stored in the heap are currently live and which objects the program can no longer reference. The areas of the heap occupied by unreferenceable objects are then returned to the virtual machine for subsequent use.
Generally, garbage collection (GC) is a form of automatic memory management that frees a programmer from having to worry about releasing no-longer used memory resources. Typically, garbage collector threads are used in the context of, or in computing environments involving, programming languages that allocate memory as objects. For example, each application (or its threads) may have a pool of data objects in its heap and garbage collector threads find out which of these objects are unreachable and reclaim them. A garbage collector thread consumes finite computing resources performing actions that manage the process of deciding what memory is to be freed and when and how such memory should be made available to an application (or application threads). Hence, a penalty for using garbage collectors is GC-created overhead leading to decreased application processing efficiency. More particularly, in garbage collected runtime environments, it is often the case that mutator or application threads must notify the garbage collector of updates they perform on object reference fields. This information can be used by the garbage collector in several ways such as to update remembered sets or for the correct operation of an incremental marking scheme.
There are many ways to implement garbage collection. One technique involves dirtying entries of a card table to notify the garbage collector which areas or “cards” of the heap contain modified objects. In another process, update buffers are generated that contain information about each update a mutator thread has performed, and garbage collector threads periodically read and process these buffers. In this latter garbage collection approach, the update buffers are typically added by the application threads or mutators to a global queue (or global input buffer queue) and removed from the global queue by the garbage collector threads. An atomic operation, such as a lock or compare and swap (CAS) operation, may be used to add and/or remove the update buffer from the queue. A point of contention may arise as buffers are added and removed from the global queue that limits scalability and performance of the computer systems that implement such a garbage collection process.
Hence, there is a need for improved methods of providing garbage collection with less contention to memory and/or other resources of a computing system. Preferably, such garbage collection methods and systems may provide data structures that cause (or allow) applications to do as little work as possible while causing the garbage collector thread(s) to do more work (e.g., create a desired asymmetry in which the garbage collectors may have more latency than the mutator threads).